#{extends 'mainFMPA.html' /} #{set title:'Détail de la FMPA' /}
#{if !fmpaQ.fmpa.etat.id_etatfmpa.equals("ATVAL") || (fmpaQ.fmpa.etat.id_etatfmpa.equals("ATVAL") && (agent_responsable || chef_CIS || admin))}
<br/>
<h1 style="width: 400px;">D&eacute;tails de la FMPA</h1>
#{if !fmpaQ.fmpa.etat.id_etatfmpa.equals("TERMI")}
<p>
	<a href="@{FMPAQuinquennals.modifFMPAForm(fmpaQ.id)}">Modifier la FMPA</a>
</p>
#{/if}
<div id="detail_fmpa">
	<p>
		<label><b> CIS : </b>
		</label>
		${fmpaQ.fmpa.cis}
	</p>
	<p>
		<label><b> Date : </b>
		</label>
		${fmpaQ.fmpa.date.format('dd MMMM yyyy', 'fr')}
	</p>
	<p>
        <label><b>Pour l'ann&eacute;e : </b></label>
        ${fmpaQ.annee}
    </p>
	<p>
		<label><b> Th&eacute;matique : </b>
		</label>
		${fmpaQ.fmpa.thematique}
	</p>
	<p>
		<label><b> Th&egrave;me : </b>
		</label> 
		#{if fmpaQ.fmpa.sousThematique.equals("") || fmpaQ.fmpa.sousThematique==null}
		 - 
		#{/if}
		#{else}
		${fmpaQ.fmpa.sousThematique}
		#{/else}
	</p>
	<p>
		<label><b> Description : </b>
		</label> 
		#{if fmpaQ.fmpa.description.equals("") || fmpaQ.fmpa.description==null}
		 - 
		#{/if}
		#{else}
		${fmpaQ.fmpa.description}
		#{/else}
	</p>
	#{list items:listSeq, as:'seq'}
	<p>
 	    <label for=${seq.nom}><b>${seq.nom}</b></label>
		#{if fmpaQ.contientSequence(seq)}
		oui
		#{/if}
		#{else}
		non
		#{/else}
    </p>
    #{/list}
	<p>
		<label><b> Observations : </b>
		</label>
		#{if fmpaQ.fmpa.observation.equals("") || fmpaQ.fmpa.observation==null}
		 - 
		#{/if}
		#{else}
		${fmpaQ.fmpa.observation}
		#{/else}
	</p>
	<p>
		<label><b> Dur&eacute;e : </b>
		</label>
		${fmpaQ.fmpa.duree}
	</p>
	<p>
		<label><b> Etat : </b>
		</label>
		#{if fmpaQ.fmpa.etat == null} - 
		#{/if} 
		#{else} ${fmpaQ.fmpa.etat} 
		#{/else}
	</p>
	<p>
		<label><b> Effectif actuel : </b>
		</label>
		#{if fmpaQ.fmpa.getEffectif() == 0} - 
		#{/if} 
		#{else} ${fmpaQ.fmpa.getEffectif()}
		#{/else}
	</p>
	#{if fmpaQ.fmpa.etat.id_etatfmpa.equals("PREVU") || fmpaQ.fmpa.etat.id_etatfmpa.equals("INVAL")}
		#{form @FMPAs.demandeValid(fmpaQ.fmpa.id)}
        <center><input type="submit" value="Demander la validation" /></center>
        #{/form}
    #{/if}
    #{if fmpaQ.fmpa.etat.id_etatfmpa.equals("ATVAL")}
        <center>
        	<input type="button" onClick="self.location.href='@{FMPAs.validerFMPA(true,fmpaQ.fmpa.id)}'" value="valider" />
        	<input type="button" onClick="self.location.href='@{FMPAs.validerFMPA(false,fmpaQ.fmpa.id)}'" value="refuser" />
        </center>
    #{/if}
    <center><input type="button" onClick="window.open('@{FMPAQuinquennals.pv(fmpaQ.id)}')" value="&eacute;diter le pv" /></center>

</div>

<div id="detail_fmpa_participants">
	<br/>
	#{if isParticipant}
	<h2 style="float: left;">Liste des participants</h2>
	<br />
	#{if !fmpaQ.fmpa.etat.id_etatfmpa.equals("TERMI")}
	<input style="float: right;" type="button" onClick="self.location.href='@{FMPAs.validerTous(fmpaQ.fmpa.id)}'" value="tout valider" />
	#{/if}
	<br />
	<table width="200" cellspacing='0' cellpadding='7' id="liste"
		class="display" summary="Liste des candidats" bgcolor="#E1EEF0">
		<thead>
			<tr>
				<th>Nom</th>
				<th>Pr&eacute;nom</th>
				<th>Grade</th>
				<th>Statut</th>
				<th>CIS</th>
				<th>R&ocirc;le</th>
				<th>FMPA valid&eacute;e</th>
				#{if !fmpaQ.fmpa.etat.id_etatfmpa.equals("TERMI")}
				<th>validation</th>
				#{/if}
			</tr>
		</thead>
		<tbody>
			#{list items:participants, as:'participant' }
			<tr>
				<td>${participant.agent.nom}</td>
				<td>${participant.agent.prenom}</td>
				<td>${participant.agent.grade}</td>
				<td>${participant.agent.statut}</td>
				<td>${participant.agent.cisService}</td>
				<td>${participant.role}</td>
				#{if participant.valide}
					<td>valide
				#{/if}
				#{else}
					<td class="attention">non valide
				#{/else}
				</td>
				#{if !fmpaQ.fmpa.etat.id_etatfmpa.equals("TERMI")}
				<td><a href="@{FMPAs.valider(participant.id,true,fmpaQ.fmpa.id)}">valider</a><br />
					<a href="@{FMPAs.valider(participant.id,false,fmpaQ.fmpa.id)}">invalider</a><br />
					<a href="@{FMPAs.retirerParticipant(participant.id,fmpaQ.fmpa.id)}">annuler</a>
				</td>
				#{/if}
			</tr>
			#{/list}
		<tbody>
	</table>
	#{/if}
	#{if !fmpaQ.fmpa.etat.id_etatfmpa.equals("TERMI")}
	<br />
	<div id="ajout">
	#{form @FMPAQuinquennals.newParticipantSave()}
	<p>
		<label for="cis"><b>CIS :</b></label> 
		#{select 'cis', items:ciss, id:'cis', valueProperty:'id', value:idCis, onChange:'change()'}
		#{/select}
	</p>
	<p id="aModifier">
		<label for="agent"><b>Agent :</b></label>
		#{select 'agent', items:agents,id:'agent', value:'0'}
		#{/select}
	</p>
	<p>
		<label for="role"><b>role :</b></label>
		#{select 'role', items:roles, valueProperty:'id', id:'role', value:idForme}
		#{/select}
	</p>
	<input type="hidden" name="fmpa" value=${fmpaQ.fmpa.id} >
	<input type="hidden" name="fmpaQ" value=${fmpaQ.id} >
	<br />
	<center><input type="submit" value="Ajouter l'agent"></center>
	#{/form}
	</div>
	#{/if}
</div>
#{/if} #{else}
<div class="empty">Cette fmpa est en attente de validation. Vous ne pouvez pas consulter cette page.</div>
#{/else}

<SCRIPT type="text/javascript">
	function change(){
	    var monCis=document.getElementById("cis").options[document.getElementById("cis").selectedIndex].value
	    $('#aModifier').load("/attraper/"+monCis)
	}
</SCRIPT>

<SCRIPT type="text/javascript">
	
	function validerFMPA(){
		load(@{FMPAs.validerFMPA(true,fmpaQ.fmpa.id)});
	}
	
	function refuserFMPA(){
		load(@{FMPAs.validerFMPA(false,fmpaQ.fmpa.id)});
	}
</SCRIPT>